package com.type;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

public class Friend extends Person {
	Boolean isOnline = false;
	String name;

	public Friend() {
		super();
	}
	
	public Friend(long phoneNumber, String name, Bitmap bitmap) {
		super(phoneNumber, bitmap);
		this.name = name;
	}
	
	public void setIsOnline(Boolean isOnline) {
		this.isOnline = isOnline;
	}
	
	public Boolean getIsOnline() {
		return isOnline;
	}
	
	public String getName() {
		return name;
	}

	
	@Override
	public void receive(DataInputStream dis) throws IOException, InterruptedException {
		super.receive(dis);
		name = dis.readUTF();
	}

	@Override
	public void send(DataOutputStream dos) throws IOException, InterruptedException {
		super.send(dos);
		dos.writeUTF(name);
	}

	
	public Friend(Parcel in) {
		super(in);
		boolean[] booleanArray = new boolean[1];
		in.readBooleanArray(booleanArray);
		isOnline = booleanArray[0];
		name = in.readString();
	}
	
	public static final Parcelable.Creator<Friend> CREATOR = new Parcelable.Creator<Friend>() {
		public Friend createFromParcel(Parcel in) {
			return new Friend(in);
		}

		@Override
		public Friend[] newArray(int size) {
			return new Friend[size];
		}
	};

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel out, int flags) {
		super.writeToParcel(out, flags);
		out.writeBooleanArray(new boolean[] {isOnline});
		out.writeString(name);
	}
}
